package marmalius;


public class Agility {
    //private int absY = 0;
    public client client1;
    public int absX = 0;
    public int objectY = 0;
    public int objectX = 0;
    public static int ObsticalTimer = 0;
    public static int LedgeTimer = 0;

    public static void process() {
        if (ObsticalTimer >= 0) {
            ObsticalTimer--;
        }
        if (LedgeTimer >= 0) {
            LedgeTimer--;
        }
    }

    public void StartAnimation(int i) {
        //PlayerHandler _tmp = PlayerHandler.getInstance();
        client1.startAnimation(i);
    }

    public void addSkillXP(int i, int j) {
        //PlayerHandler _tmp = PlayerHandler.getInstance();
        client1.addSkillXP(i, j);
    }

    public void TeleTo(int i, int j) {
        //PlayerHandler _tmp = PlayerHandler.getInstance();

        client1.teleportToX = i;
        client1.teleportToY = j;
    }

    public void WalkTo(int i, int j) {
        //PlayerHandler _tmp = PlayerHandler.getInstance();
        client1.WalkTo(i, j);
    }

    public void WalkToEmote(int i) {
        //PlayerHandler _tmp = PlayerHandler.getInstance();
        client1.playerSEW = i;
    }

    public void StopWalkToEmote() {
        //PlayerHandler _tmp = PlayerHandler.getInstance();
        client1.playerSEW = 819;
    }

    public void useAgility(int objectID, int ID) {
        client c = (client)PlayerHandler.getInstance().getPlayer(ID);
        int l = c.absX;
        int i1 = c.absY;
        int j = c.absX;
        int k = c.absY;

        switch (objectID) {
        default:
            break;
 
        case 2295: 
            if (c.ObsticalTimer <= 0) {
                c.sendMessage("You balance across the log!");
                c.ObsticalTimer = 8;
                c.WalkToEmote(762);
                c.WalkTo(0, -7);
                c.addSkillXP(50, 16);
                c.Stage1 = 1;
            }
            break;

        case 2285: 
            if (c.ObsticalTimer <= 0) {
                c.startAnimation(828);
                c.sendMessage("You climb the net");
                c.TeleTo(l, i1 - 3);
                c.heightLevel = 1;
                c.addSkillXP(50 * c.playerLevel[16], 16);
                c.Stage2 = 1;
            }
            break;

        case 2313: 
            if (c.ObsticalTimer <= 0) {
                c.startAnimation(828);
                c.TeleTo(l, i1 - 3);
                c.sendMessage("You climb the tree branch");
                c.heightLevel = 2;
                c.addSkillXP(50 * c.playerLevel[16], 16);
                c.Stage3 = 1;
            }
            break;

        case 2312: 
            if (c.ObsticalTimer <= 0) {
                c.sendMessage("You balance across the rope");
                c.ObsticalTimer = 6;
                c.WalkToEmote(762);
                c.WalkTo(6, 0);
                c.addSkillXP(50, 16);
                c.Stage4 = 1;
            }
            break;

        case 2314: 
        case 2315: 
            if (c.ObsticalTimer <= 0) {
                c.startAnimation(828);
                c.TeleTo(2487, 3420);
                c.sendMessage("You climb down the tree branch");
                c.heightLevel = 0;
                c.addSkillXP(50 * c.playerLevel[16], 16);
                c.Stage5 = 1;
                c.ObsticalTimer = 10;
            }
            break;

        case 2286: 
            if (c.ObsticalTimer <= 0) {
                c.startAnimation(828);
                c.WalkTo(0, 2);
                c.sendMessage("You climb over the net");
                c.heightLevel = 0;
                c.addSkillXP(50 * c.playerLevel[16], 16);
                c.Stage6 = 1;
            }
            break;

        case 154: 
        case 4058: 
            if (c.Stage1 >= 1 && c.Stage2 >= 1 && c.Stage3 >= 1 && c.Stage4 >= 1
                    && c.Stage5 >= 1 && c.Stage6 >= 1) {
                if (c.ObsticalTimer <= 0) {
                    c.sendMessage("You squeeze through the pipe");
                    c.ObsticalTimer = 6;
                    c.WalkToEmote(746);
                    c.WalkTo(0, 7);
                    c.addSkillXP(7500, 16);
                    c.Stage1 = 0;
                    c.Stage2 = 0;
                    c.Stage3 = 0;
                    c.Stage4 = 0;
                    c.Stage5 = 0;
                    c.Stage6 = 0;
                }
            } else {
                c.sendMessage("You need to finish the other obsticals before completing the course");
            }
            break;

        case 2287: 
            c.sendMessage("You squeeze through the pipe");
            c.ObsticalTimer = 6;
            c.WalkToEmote(749);
            c.WalkTo(0, -3);
            c.addSkillXP(150, 16);
            break;

        case 2282: 
            if (i1 == k - 4) {
                c.sendMessage("You swing across the pit");
                c.ObsticalTimer = 5;
                c.WalkToEmote(751);
                c.WalkTo(0, -5);
                c.addSkillXP(75, 16);
            }
            break;

        case 2294: 
            c.sendMessage("You balance across the log!");
            c.ObsticalTimer = 12;
            c.WalkToEmote(762);
            c.WalkTo(-9, 0);
            c.addSkillXP(50, 16);
            break;

        case 2284: 
            c.startAnimation(828);
            c.sendMessage("You climb the net");
            c.TeleTo(l - 2, i1);
            c.heightLevel = 1;
            c.addSkillXP(75, 16);
            break;

        case 2302: 
            c.sendMessage("You walk across the ledge");
            c.LedgeTimer = 3;
            c.WalkToEmote(756);
            c.WalkTo(-4, 0);
            c.addSkillXP(75, 16);
            break;

        case 3205: 
            c.absX = 2532;
            c.absY = 3545;
            c.startAnimation(828);
            c.sendMessage("You climb down the ladder");
            c.heightLevel = 0;
            break;

        case 1948: 
            if (j == 2536 && k == 3553) {
                c.sendMessage("You climb over the wall");
                c.ObsticalTimer = 4;
                c.WalkToEmote(839);
                c.WalkTo(3, 0);
                c.addSkillXP(75, 16);
                break;
            }
            if (j == 2539 && k == 3553) {
                c.sendMessage("You climb over the wall");
                c.ObsticalTimer = 4;
                c.WalkToEmote(839);
                c.WalkTo(3, 0);
                c.addSkillXP(75, 16);
                break;
            }
            if (j == 2542 && k == 3553) {
                c.sendMessage("You climb over the wall");
                c.ObsticalTimer = 4;
                c.WalkToEmote(839);
                c.WalkTo(3, 0);
                c.addSkillXP(75, 16);
            }
            break;

        case 5138: 
            j = 3538;
            k = 9875;
            c.startAnimation(839);
            c.TeleTo(3540, 9882);
            c.sendMessage("You jump the stepping stones");
            c.heightLevel = 0;
            c.addSkillXP(90 * c.playerLevel[16], 16);
            break;

        case 5133: 
        case 5134: 
        case 5135: 
            c.sendMessage("You jump over the hurdle");
            c.ObsticalTimer = 4;
            c.WalkToEmote(2750);
            c.WalkTo(0, 2);
            c.addSkillXP(75, 16);
            break;

        case 5152: 
            c.sendMessage("You squeeze through the pipe");
            c.ObsticalTimer = 6;
            c.WalkToEmote(746);
            c.WalkTo(0, 6);
            c.addSkillXP(75, 16);
            break;

        case 5136: 
            c.sendMessage("You climb the slope");
            c.ObsticalTimer = 4;
            c.WalkToEmote(737);
            c.WalkTo(-4, 0);
            c.addSkillXP(75, 16);
            break;

        case 5141: 
            j = 3529;
            k = 9910;
            c.startAnimation(844);
            c.TeleTo(3528, 9872);
            c.sendMessage("You zip down the zipline");
            c.heightLevel = 0;
            c.addSkillXP(90, 16);
            break;

        case 2288: 
            j = 3004;
            k = 3938;
            c.sendMessage("You squeeze through the pipe");
            c.ObsticalTimer = 14;
            c.WalkToEmote(746);
            c.WalkTo(0, 13);
            c.addSkillXP(150, 16);
            break;

        case 2283: 
            c.sendMessage("You swing on the ropeswing");
            c.startAnimation(751);
            c.TeleTo(3005, 3958);
            c.addSkillXP(150, 16);
            // fall through
            break;

        case 2311: 
            c.sendMessage("You jump accross the stepping stones");
            c.ObsticalTimer = 7;
            c.WalkToEmote(741);
            c.WalkTo(-6, 0);
            c.addSkillXP(150, 16);
            break;

        case 2297: 
            c.sendMessage("You balance across the log");
            c.ObsticalTimer = 9;
            c.WalkToEmote(762);
            c.WalkTo(-8, 0);
            c.addSkillXP(150, 16);
            break;

        case 2328: 
            c.sendMessage("You climb the rocks");
            c.ObsticalTimer = 6;
            c.WalkToEmote(737);
            c.WalkTo(0, -5);
            c.addSkillXP(150, 16);
            break;

        case 9295: 
            if (j == 3150 && k == 9906) {
                c.sendMessage("You squeeze through the pipe");
                c.ObsticalTimer = 7;
                c.WalkToEmote(746);
                c.WalkTo(6, 0);
                c.addSkillXP(50, 16);
                break;
            }
            if (j == 3153 && k == 9906) {
                c.sendMessage("You squeeze through the pipe");
                c.ObsticalTimer = 7;
                c.WalkToEmote(746);
                c.WalkTo(-6, 0);
                c.addSkillXP(50, 16);
            }
            break;

        case 2320: 
            if (j == 3119 || j == 3120 && k == 9964) {
                c.sendMessage("You squeeze through the pipe");
                c.ObsticalTimer = 8;
                c.WalkToEmote(744);
                c.WalkTo(0, 7);
                c.addSkillXP(50, 16);
                break;
            }
            if (j == 3119 || j == 3120 && k == 9969) {
                c.sendMessage("You squeeze through the pipe");
                c.ObsticalTimer = 8;
                c.WalkToEmote(744);
                c.WalkTo(0, -7);
                c.addSkillXP(50, 16);
            }
            break;

        case 9293: 
            if (j == 2887 && k == 9799) {
                if (c.playerLevel[16] > 59) {
                    c.sendMessage("You squeeze through the pipe");
                    c.ObsticalTimer = 7;
                    c.WalkToEmote(746);
                    c.WalkTo(6, 0);
                    c.addSkillXP(50, 16);
                } else {
                    c.sendMessage("You need an agility level of 60 to do this");
                }
                break;
            }
            if (j != 2890 || k != 9799) {
                break;
            }
            if (c.playerLevel[16] > 59) {
                c.sendMessage("You squeeze through the pipe");
                c.ObsticalTimer = 7;
                c.WalkToEmote(746);
                c.WalkTo(-6, 0);
                c.addSkillXP(50, 16);
            } else {
                c.sendMessage("You need an agility level of 60 to do this");
            }
            break;

        case 9294: 
            if (l == 2880 && i1 == 9813) {
                if (c.playerLevel[16] > 74) {
                    c.sendMessage("You jump over the strange floor");
                    c.ObsticalTimer = 2;
                    c.WalkToEmote(3067);
                    c.WalkTo(-2, 0);
                    c.addSkillXP(100, 16);
                } else {
                    c.sendMessage("You need an agility level of 75 to do this");
                }
                break;
            }
            if (l != 2878 || i1 != 9813) {
                break;
            }
            if (c.playerLevel[16] > 74) {
                c.sendMessage("You jump over the strange floor");
                c.ObsticalTimer = 2;
                c.WalkToEmote(3067);
                c.WalkTo(2, 0);
                c.addSkillXP(100, 16);
            } else {
                c.sendMessage("You need an agility level of 75 to do this");
            }
            break;

        case 9330: 
            if (l == 2601 && i1 == 3336) {
                if (c.playerLevel[16] > 9) {
                    c.sendMessage("You balance across the log");
                    c.ObsticalTimer = 5;
                    c.WalkToEmote(762);
                    c.WalkTo(-4, 0);
                    c.addSkillXP(20, 16);
                } else {
                    c.sendMessage("You need an agility level of 10 to do this");
                }
                break;
            }
            if (l != 2559 || i1 != 3336) {
                break;
            }
            if (c.playerLevel[16] > 9) {
                c.sendMessage("You balance across the log");
                c.ObsticalTimer = 5;
                c.WalkToEmote(762);
                c.WalkTo(4, 0);
                c.addSkillXP(20, 16);
            } else {
                c.sendMessage("You need an agility level of 10 to do this");
            }
            break;

        case 2296: 
            if (j == 2602 && k == 3477) {
                if (c.playerLevel[16] > 9) {
                    c.sendMessage("You balance across the log");
                    c.ObsticalTimer = 6;
                    c.WalkToEmote(762);
                    c.WalkTo(-5, 0);
                    c.addSkillXP(20, 16);
                } else {
                    c.sendMessage("You need an agility level of 10 to do this");
                }
                break;
            }
            if (j != 2599 || k != 3477) {
                break;
            }
            if (c.playerLevel[16] > 9) {
                c.sendMessage("You balance across the log");
                c.ObsticalTimer = 6;
                c.WalkToEmote(762);
                c.WalkTo(5, 0);
                c.addSkillXP(20, 16);
            } else {
                c.sendMessage("You need an agility level of 10 to do this");
            }
            break;

        case 11844: 
            if (l == 2936 && i1 == 3355) {
                if (c.playerLevel[16] > 4) {
                    c.ObsticalTimer = 4;
                    c.WalkToEmote(882);
                    c.WalkTo(-2, 0);
                    c.addSkillXP(10, 16);
                } else {
                    c.sendMessage("You need an agility level of 5 to do this");
                }
                break;
            }
            if (l != 2934 || i1 != 3355) {
                break;
            }
            if (c.playerLevel[16] > 4) {
                c.ObsticalTimer = 4;
                c.WalkToEmote(882);
                c.WalkTo(2, 0);
                c.addSkillXP(10, 16);
            } else {
                c.sendMessage("You need an agility level of 5 to do this");
            }
            break;
        }       
    }
}
